<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:cc="http://java.sun.com/jsf/composite/customcomponents"
	contentType="text/html">
	
	<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><h:outputText value="#{label['ExampleFunctions.title']} - #{label['appNameTitle']}"/></title>
		
		<style>
			.panelGridCenter {
	    		margin: 0 auto;
			}		
		</style>
	</h:head>	
	<h:body>
		<cc:LatamHeader userInfo="true">
			<cc:AppHeaderMenu/>
		</cc:LatamHeader>
		
		<p:growl id="growl" severity="info,error,warn"/>
			
		<p:panel styleClass="latam_body_panel">
			<p:fieldset legend="#{label['ExampleFunctions.flash.title']}" toggleable="true" collapsed="true">
				<h:form>			
					<p:fieldset legend="Flash Context">
						<p:panel styleClass="no-border">
							<p:panelGrid columns="2" styleClass="panelGridCenter">
								<p:outputLabel value="#{label['ExampleFunctions.flash.objectToSend']}: "/>
								<p:inputText value="#{exampleFlashScopeSender.theObjectForOtherPage}"/>
							</p:panelGrid>
							<p:panelGrid columns="2" styleClass="panelGridCenter">
								<p:commandButton value="#{label['ExampleFunctions.flash.send']}" action="#{exampleFlashScopeSender.sendTheObject}"/>
							</p:panelGrid>
						</p:panel>
					</p:fieldset>
				</h:form>
				
				<br/>
				
				<h:form>
					<p:fieldset legend="#{label['ExampleFunctions.flash.titleEL']}">
						<p:panel styleClass="no-border">
							<p:panelGrid columns="2" styleClass="panelGridCenter">
								<p:outputLabel value="#{label['ExampleFunctions.flash.objectToSend']}: "/>
								<p:inputText value="#{exampleFlashScopeSender.theObjectForOtherPage}"/>
							</p:panelGrid>
							<p:panelGrid columns="2" styleClass="panelGridCenter">
								<p:commandButton value="#{label['ExampleFunctions.flash.send']}" action="#{exampleFlashScopeSender.sendTheObject(exampleFlashScopeSender.theObjectForOtherPage)}"/>
							</p:panelGrid>
						</p:panel>
					</p:fieldset>
					
				</h:form>
			</p:fieldset>
			
			<br/>
			
			<p:fieldset legend="#{label['ExampleFunctions.rules.title']}" toggleable="true" collapsed="true">
				<h:form>
					<p:panel styleClass="no-border">
						<p:panelGrid columns="2" styleClass="panelGridCenter"> 		
								
							<p:panelGrid columns="3" styleClass="panelGridCenter">
								<p:spacer/>
								<p:outputLabel value="Bean 1" style="font-weight: bolder; font-size: 14px;"/>
								<p:spacer/>
							
								<p:outputLabel value="#{label['ExampleFunctions.rules.name']}: "/>
								<p:inputText id="bean1Name" value="#{exampleDynamicRule.bean1.name}"/>
								<p:message for="bean1Name"/>
								
								<p:outputLabel value="#{label['ExampleFunctions.rules.value']}: "/>
								<p:inputText id="bean1Value" value="#{exampleDynamicRule.bean1.numValue}"/>
								<p:message for="bean1Value"/>
							</p:panelGrid>
	
							<p:panelGrid columns="3" styleClass="panelGridCenter">
								<p:spacer/>
								<p:outputLabel value="Bean 2" style="font-weight: bolder; font-size: 14px;"/>
								<p:spacer/>

								<p:outputLabel value="#{label['ExampleFunctions.rules.name']}: "/>
								<p:inputText id="bean2Name" value="#{exampleDynamicRule.bean2.name}"/>
								<p:message for="bean2Name"/>
								
								<p:outputLabel value="#{label['ExampleFunctions.rules.value']}: "/>
								<p:inputText id="bean2Value" value="#{exampleDynamicRule.bean2.numValue}"/>
								<p:message for="bean2Value"/>
							</p:panelGrid>
	
						</p:panelGrid>
						<p:panel>
							<p:panelGrid columns="2" styleClass="panelGridCenter">
								<p:outputLabel value="#{label['ExampleFunctions.rules.rule']}:"/>
								<p:inputText value="#{exampleDynamicRule.rule}" style="width: 600px;"/>
								<p:outputLabel value="#{label['ExampleFunctions.rules.output']}:"/>
								<h:outputText value="#{exampleDynamicRule.value}" style="color: red; font-weight: bold; font-size: 14px;"/>
							</p:panelGrid>			
							<p:panelGrid columns="1" styleClass="panelGridCenter">
								<p:commandButton value="#{label['ExampleFunctions.rules.validate']}" action="#{exampleDynamicRule.performRuleValidation}" update="@form"/>
							</p:panelGrid>
						</p:panel>
					</p:panel>
				</h:form>				
			</p:fieldset>
			
			<br/>
			
			<p:fieldset legend="#{label['ExampleFunctions.files.title']}" toggleable="true" collapsed="true">
				<h:form>
					<p:panel styleClass="no-border">
						<p:panelGrid columns="2" styleClass="panelGridCenter">
							<p:fileUpload 																	
			            		fileUploadListener="#{exampleFileManager.uploadFile}"
			            		label="#{label['ExampleFunctions.files.upload']}"
			            		multiple="true"
			            		auto="true"
			            		showButtons="false"
			            		mode="advanced"
			            		update="@all"/>
							<p:commandButton value="#{label['ExampleFunctions.files.download']}" 
								onclick="PrimeFaces.monitorDownload( showDownloadDialog, hideDownloadStop );"
								ajax="false" update="@all">
								<p:fileDownload value="#{exampleFileManager.file}"/>
							</p:commandButton>												            			
						</p:panelGrid>
					</p:panel>
				</h:form>				
			</p:fieldset>
			
			<br/>

			<p:fieldset legend="#{label['ExampleFunctions.timer.title']}" toggleable="true" collapsed="true">
				<h:form>			
					<p:panel styleClass="no-border">
						<p:panelGrid id="timerStatusPanel" columns="2" styleClass="panelGridCenter"> 
							<p:outputLabel value="#{label['ExampleFunctions.timer.lastExecution']}:"/>
							<p:outputLabel value="#{exampleTimerController.lastExecution}">
								<f:convertDateTime pattern="EEE, dd/MM/yyyy HH:mm:ss" locale="#{userLanguage.locale}"/>
							</p:outputLabel>
							
							<p:outputLabel value="#{label['ExampleFunctions.timer.delayInterval']}:"/>
							<p:inputText value="#{exampleTimerController.delayInterval}"/>
							
							<p:outputLabel value="#{label['ExampleFunctions.timer.status']}:"/>
							<h:outputText value="#{exampleTimerController.status}" style="font-weight:bold; color: ${exampleTimerController.status=='Stopped'?'red':'green'}"/>
						</p:panelGrid>
						<br/>
						<p:panelGrid columns="3" styleClass="panelGridCenter"> 
							<p:commandButton value="#{label['ExampleFunctions.timer.enableTimer']}" action="#{exampleTimerController.enableTimer}" update="timerStatusPanel"/>
							<p:commandButton value="#{label['ExampleFunctions.timer.disableTimer']}" action="#{exampleTimerController.disableTimer}" update="timerStatusPanel"/>
							<p:commandButton value="#{label['ExampleFunctions.timer.updateInformation']}" update="timerStatusPanel"/>
						</p:panelGrid>						
					</p:panel>
				</h:form>
			</p:fieldset>
			
			<br/>
			
			<p:fieldset legend="#{label['ExampleFunctions.mail.title']}" toggleable="true" collapsed="true">
				<h:form>			
					<p:panel styleClass="no-border">
						<p:panelGrid columns="2" styleClass="panelGridCenter"> 
							<p:outputLabel value="#{label['ExampleFunctions.mail.destination']}:"/>
							<p:inputText value="#{exampleMailSender.destination}" size="40"/>
						
							<p:outputLabel value="#{label['ExampleFunctions.mail.content']}:"/>
							<p:editor value="#{exampleMailSender.content}" width="500"/>
						</p:panelGrid>
						<br/>
						<p:panelGrid columns="1" styleClass="panelGridCenter"> 
							<p:commandButton value="#{label['ExampleFunctions.mail.send']}" action="#{exampleMailSender.sendMail}" update=":growl"/>
						</p:panelGrid>						
					</p:panel>
				</h:form>
			</p:fieldset>
			
			<br/>
			
			<p:fieldset legend="#{label['ExampleFunctions.logger.title']}" toggleable="true" collapsed="true">
				<h:form>			
					<p:panel styleClass="no-border">
						<p:panelGrid columns="2" styleClass="panelGridCenter"> 
							<p:outputLabel value="#{label['ExampleFunctions.logger.level']}:"/>
							<p:selectOneMenu id="levelName" value="#{exampleLoggerManager.levelName}">
								<f:selectItem itemLabel="TRACE" itemValue="TRACE"/>
								<f:selectItem itemLabel="DEBUG" itemValue="DEBUG"/>
								<f:selectItem itemLabel="INFO" itemValue="INFO"/>
								<f:selectItem itemLabel="WARN" itemValue="WARN"/>
								<f:selectItem itemLabel="ERROR" itemValue="ERROR"/>
								<f:selectItem itemLabel="OFF" itemValue="OFF"/>
							</p:selectOneMenu>
						</p:panelGrid>
						<br/>
						<p:panelGrid columns="1" styleClass="panelGridCenter"> 
							<p:commandButton value="#{label['ExampleFunctions.logger.testLogger']}" 
								action="#{exampleLoggerManager.testLogger}" 
								update=":growl levelName"/>
						</p:panelGrid>						
					</p:panel>
				</h:form>
			</p:fieldset>
			
			<br/>
			
			<p:fieldset legend="#{label['ExampleFunctions.jndi.title']}" toggleable="true" collapsed="true">
				<h:form>			
					<p:panel styleClass="no-border">
						<p:panelGrid columns="1" styleClass="panelGridCenter"> 
							<p:commandButton value="#{label['ExampleFunctions.jndi.test']}" 
								action="#{exampleLocalLookup.testLookup}" 
								update=":growl"/>
						</p:panelGrid>						
					</p:panel>
				</h:form>
			</p:fieldset>							
		</p:panel>
		
		<p:dialog modal="true" widgetVar="downloadDialog" header="#{label['ExampleFunctions.files.generating']}" draggable="false" closable="false" resizable="false">
			<center>  
   				<p:graphicImage value="/resources/images/ajax-loader.gif" />
   				<p:outputLabel value="#{label['ExampleFunctions.files.generating']}"/>
   			</center>  
		</p:dialog>
		<script type="text/javascript">  
			function showDownloadDialog() {  
				downloadDialog.show();  
			}  
			  
			function hideDownloadStop() {  
				downloadDialog.hide();  
			}  
		</script>
		
		<cc:LatamFooter/>
	</h:body>
	
</f:view>